You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: improve CLI startup speed and local build speed - #2279
Since I hadn't gotten feedback on #2269 yet, I've opened the pr to showcase the startup speed improvements, along with a couple of quick build speed optimizations I found while working on it.
What's in this PR:
CLI Startup Speed (Lazy Loading)
Converted the top-level @asyncapi/parser import in src/apps/cli/internal/base.ts to import type and added a lazy getter/loader. Now, running basic commands doesn't parse @asyncapi/parser right away.
Deferred loading ValidationService, ValidationStatus, and ConversionService in validate.ts and convert.ts until run() or diagnostic handlers execute.
Local Build Speed (tsc --incremental)
Added "incremental": true and "tsBuildInfoFile": "./.tsbuildinfo" to tsconfig.json (and added .tsbuildinfo to .gitignore). This caches AST metadata so tsc doesn't re-compile all ~200 files from scratch on minor edits.
Skipping Example ZIP Downloads on Build
Updated scripts/fetch-asyncapi-example.js to check if assets/examples/examples.json already exists locally before fetching the 2MB zip from GitHub. I also added a FORCE_FETCH_EXAMPLES=true environment flag in case anyone wants to force a fresh download.
Benchmarks (Tested on my machine)
Local Build (npm run build): Dropped from ~19.75s down to ~6.15s (saving ~13.6 seconds per build).
CLI Startup (time ./bin/run_bin config): Dropped from ~2.37s down to ~1.76s.
Test Suite: All 382 tests passing cleanly.
Question for Maintainers
Does skipping the spec example download when examples.json already exists locally look okay to you, or would you prefer a different flag/approach for fetching examples during builds?
The reason will be displayed to describe this comment to others. Learn more.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request. Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
Okay, the review of this PR is taking too long. So I'm making it ready for review right away. I will be instantly available for follow-ups and requested changes.
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
hey @AayushSaini101@princerajpoot20 please look into this when you have a moment and let me know if there are any adjustments needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello!
Since I hadn't gotten feedback on #2269 yet, I've opened the pr to showcase the startup speed improvements, along with a couple of quick build speed optimizations I found while working on it.
What's in this PR:
CLI Startup Speed (Lazy Loading)
@asyncapi/parserimport insrc/apps/cli/internal/base.tstoimport typeand added a lazy getter/loader. Now, running basic commands doesn't parse@asyncapi/parserright away.ValidationService,ValidationStatus, andConversionServiceinvalidate.tsandconvert.tsuntilrun()or diagnostic handlers execute.Local Build Speed (
tsc --incremental)"incremental": trueand"tsBuildInfoFile": "./.tsbuildinfo"totsconfig.json(and added.tsbuildinfoto.gitignore). This caches AST metadata sotscdoesn't re-compile all ~200 files from scratch on minor edits.Skipping Example ZIP Downloads on Build
scripts/fetch-asyncapi-example.jsto check ifassets/examples/examples.jsonalready exists locally before fetching the 2MB zip from GitHub. I also added aFORCE_FETCH_EXAMPLES=trueenvironment flag in case anyone wants to force a fresh download.Benchmarks (Tested on my machine)
npm run build): Dropped from ~19.75s down to ~6.15s (saving ~13.6 seconds per build).time ./bin/run_bin config): Dropped from ~2.37s down to ~1.76s.Question for Maintainers
Does skipping the spec example download when
examples.jsonalready exists locally look okay to you, or would you prefer a different flag/approach for fetching examples during builds?